<template>
    <div>
        <!-- 搜索容器 -->
        <div class="search-container">
            <span class="search-label">菜单名称：</span>
            <el-input v-model="input" placeholder="搜索菜单" class="search-input"></el-input>

            <el-button type="primary" class="search-button">查询</el-button>
            <el-button type="success" class="search-button">重置</el-button>
            
            <!-- 下拉框 -->
            <el-select v-model="value" placeholder="请选择" class="search-select">
                <el-option 
                    v-for="item in options" 
                    :key="item.value" 
                    :label="item.label" 
                    :value="item.value">
                </el-option>
            </el-select>
        </div>

        <!-- 表格：移除所有列的width属性，实现自动均分 -->
        <el-table 
            :data="tableData" 
            border 
            style="width: 100%; margin-top: 15px;"
            :header-cell-style="headerCellStyle"
            :cell-style="cellStyle">

            <!-- 1. 菜单ID列 - 移除width属性 -->
            <el-table-column 
                prop="menuId" 
                label="菜单ID">
            </el-table-column>

            <!-- 2. 菜单名称列 - 移除width属性 -->
            <el-table-column 
                prop="menuName" 
                label="菜单名称">
            </el-table-column>

            <!-- 3. 父级ID列 - 移除width属性 -->
            <el-table-column 
                prop="parentId" 
                label="父级ID">
            </el-table-column>

            <!-- 4. 状态列 - 移除width属性 -->
            <el-table-column 
                prop="status" 
                label="状态">
                <template slot-scope="scope">
                    <el-tag :type="scope.row.status === '启用' ? 'success' : 'danger'">
                        {{ scope.row.status }}
                    </el-tag>
                </template>
            </el-table-column>

            <!-- 5. 操作列 - 移除width属性和fixed属性 -->
            <el-table-column 
                label="操作">
                <template slot-scope="scope">
                    <el-button @click="handleEdit(scope.row)" type="text" size="small">编辑</el-button>
                    <el-button @click="handleDelete(scope.row)" type="text" size="small"
                        style="color:#f56c6c">删除</el-button>
                </template>
            </el-table-column>
        </el-table>

        <!-- 分页组件 -->
        <el-pagination 
            class="pagination-left" 
            background 
            layout="prev, pager, next" 
            :total="1000">
        </el-pagination>
    </div>
</template>

<script>
export default {
    methods: {
        handleEdit(row) {
            console.log('编辑', row);
        },
        handleDelete(row) {
            console.log('删除', row);
        }
    },
    data() {
        return {
            input: '',
            value: '',
            headerCellStyle: {
                textAlign: 'center',
                background: '#f5f7fa',
                fontWeight: 'bold',
                height: '50px'
            },
            cellStyle: {
                textAlign: 'center',
                height: '50px'
            },
            options: [
                { value: 'option1', label: '选项1' },
                { value: 'option2', label: '选项2' },
                { value: 'option3', label: '选项3' }
            ],
            tableData: [
                {
                    menuId: '1001',
                    menuName: '系统管理',
                    parentId: '0',
                    status: '启用'
                },
                {
                    menuId: '1002',
                    menuName: '用户管理',
                    parentId: '1001',
                    status: '启用'
                },
                {
                    menuId: '1003',
                    menuName: '角色管理',
                    parentId: '1001',
                    status: '禁用'
                },
                {
                    menuId: '1004',
                    menuName: '权限管理',
                    parentId: '1001',
                    status: '启用'
                }
            ]
        }
    }
}
</script>

<style>
/* 保持原有样式不变 */
.search-container {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    padding: 10px 0;
}

.search-label {
    white-space: nowrap;
    font-size: 14px;
    color: #606266;
}

.search-input {
    width: 200px;
}

.search-button {
    margin: 0;
}

.search-select {
    width: 200px;
    margin: 0;
}

.el-table {
    margin-top: 15px;
    font-size: 14px;
}

.el-table .el-tag {
    padding: 0 12px;
    height: 28px;
    line-height: 28px;
}

.el-table .el-button--text {
    margin: 0 5px;
    font-size: 13px;
}

.pagination-left {
    margin-top: 15px;
    text-align: left;
}
</style>
